package com.ts.enterprise.common.handle;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;

/**
 * @author Administrator
 */
public class AddressListTypeHandler extends JacksonTypeHandler {

    public AddressListTypeHandler(Class<?> type) {
        super(type);
    }

    @Override
    protected Object parse(String json) {
        try {
            if (StringUtils.isNotEmpty(json)){
                return JSONObject.parseArray(json, String.class);
            }
            return new ArrayList<>();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
